from django.conf.urls.defaults import *
from django.conf import settings
from blogs.models import Blog, Post
from blogs.feeds import LatestPosts

blogs = {
    'queryset': Blog.objects.all(),
    'paginate_by': 5,
    'extra_context': {
        'blogs_media_prefix': settings.BLOGS_MEDIA_PREFIX,
        'jquery_prefix': settings.JQUERY_PREFIX,
        'tiny_mce_prefix': settings.TINY_MCE_PREFIX,
    }    
}

feeds = {
    'latest': LatestPosts
}

urlpatterns = patterns('',
    # Dashboard stuff
    (r'^dashboard/login/$', 'django.contrib.auth.views.login', {'template_name': 'blogs/login.html'}),
    (r'^dashboard/$', 'blogs.admin.index'),
    (r'^dashboard/logout/$', 'blogs.admin.logout'),
    (r'^dashboard/(?P<blog_slug>.+)/upload_image/$', 'blogs.admin.upload_image'),
    (r'^dashboard/(?P<blog_slug>.+)/ban/$', 'blogs.admin.ban_ip'),
    (r'^dashboard/(?P<blog_slug>.+)/unban/$', 'blogs.admin.unban_ip'),
    (r'^dashboard/(?P<blog_slug>.+)/banned/$', 'blogs.admin.banned_ips'),
    (r'^dashboard/(?P<blog_slug>.+)/post/add/$', 'blogs.admin.post_add'),
    (r'^dashboard/(?P<blog_slug>.+)/post/(?P<post_slug>.+)/delete/$', 'blogs.admin.post_delete'),
    (r'^dashboard/(?P<blog_slug>.+)/post/(?P<post_slug>.+)/$', 'blogs.admin.post_edit'),
    (r'^dashboard/(?P<blog_slug>.+)/comments/(?P<comment_id>\d+)/delete/$', 'blogs.admin.comment_delete'),
    (r'^dashboard/(?P<blog_slug>.+)/comments/delete/$', 'blogs.admin.comment_mass_delete'),
    (r'^dashboard/(?P<blog_slug>.+)/comments/(?P<comment_id>\d+)/$', 'blogs.admin.comment_edit'),
    (r'^dashboard/(?P<blog_slug>.+)/comments/$', 'blogs.admin.comments'),
    (r'^dashboard/(?P<blog_slug>.+)/blogroll/(?P<link_id>\d+)/delete/$', 'blogs.admin.link_delete'),
    (r'^dashboard/(?P<blog_slug>.+)/blogroll/delete/$', 'blogs.admin.link_mass_delete'),
    (r'^dashboard/(?P<blog_slug>.+)/blogroll/add/$', 'blogs.admin.link_add'),
    (r'^dashboard/(?P<blog_slug>.+)/blogroll/(?P<link_id>\d+)/$', 'blogs.admin.link_edit'),
    (r'^dashboard/(?P<blog_slug>.+)/blogroll/$', 'blogs.admin.blogroll'),
    (r'^dashboard/(?P<blog_slug>.+)/details/$', 'blogs.admin.blog_details'),
    (r'^dashboard/(?P<blog_slug>.+)/$', 'blogs.admin.dashboard'),
    
    # Feeds
    (r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
    
    # Search
    (r'^search/(?P<blog_slug>.+)/$', 'blogs.main.search'),
    
    # Yummy blog stuff
    (r'^(?P<blog_slug>.+)/ajax/comments/(?P<post_id>\d+)/$', 'blogs.ajax.comments'),
    (r'^(?P<blog_slug>.+)/tags/(?P<tag_name>.+)/$', 'blogs.main.tag'),
    (r'^(?P<blog_slug>.+)/tags/$', 'blogs.main.tags'),
    (r'^(?P<blog_slug>.+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<post_slug>.+)/$', 'blogs.main.post'),
    (r'^(?P<blog_slug>.+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/page/(?P<page_num>\d+)/$', 'blogs.main.archives_day_page'),
    (r'^(?P<blog_slug>.+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$', 'blogs.main.archives_day'),
    (r'^(?P<blog_slug>.+)/(?P<year>\d{4})/(?P<month>\d{2})/page/(?P<page_num>\d+)/$', 'blogs.main.archives_month_page'),
    (r'^(?P<blog_slug>.+)/(?P<year>\d{4})/(?P<month>\d{2})/$', 'blogs.main.archives_month'),
    (r'^(?P<blog_slug>.+)/(?P<year>\d{4})/page/(?P<page_num>\d+)/$', 'blogs.main.archives_year_page'),
    (r'^(?P<blog_slug>.+)/(?P<year>\d{4})/$', 'blogs.main.archives_year'),
    (r'^(?P<blog_slug>.+)/page/(?P<page_num>\d+)/$', 'blogs.main.page'),
    (r'^(?P<blog_slug>.+)/$', 'blogs.main.index'),
    (r'^$', 'django.views.generic.list_detail.object_list', blogs),
)
